<template>
  <div class="app">
    <h2>我是App组件</h2>
    <h3>子给的玩具：{{ wanju }}</h3>
    <h3>子给的电脑：{{ diannao }}</h3>
    <br>
    <Child 
      @send-toy="getToy" 
      @send-computer="getComputer"
    /> 
    <br>
  </div>
</template>

<script>
  import Child from './components/Child.vue'
  export default {
    name:'App',
    components:{Child},
    data() {
      return {
        wanju:'',
        diannao:''
      }
    },
    methods: {
      // value是触发send-toy事件时携带的数据
      getToy(value){
        // console.log('App',value)
        this.wanju = value
      },
      getComputer(value){
        // console.log('App',value)
        this.diannao = value
      }
    },
  }
</script>

<style>
  .app {
    background-color: #ddd;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 0 10px;
  }
</style>